package com.second.market.controller;

import com.second.common.pojo.RR;
import com.second.market.pojo.entity.Advertise;
import com.second.market.pojo.entity.TbCustomerIssues;
import com.second.market.pojo.vo.AdvertiseVo;
import com.second.market.pojo.vo.CustomerVo;
import com.second.market.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-second
 * @description: 客服问答的控制类
 * @author: 邓衡
 * @create: 2021-07-24 15:11
 **/
@RestController
@RequestMapping("market/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    //初始化查询
    @PostMapping("initcustomerTable/{currentPage}/{pageSize}")
    public RR initcustomerTable(@PathVariable("currentPage") Integer currentPage,
                                 @PathVariable("pageSize") Integer pageSize,
                                 @RequestBody CustomerVo customerVo
    ){
        return customerService.finAllcustomerByPage(currentPage,pageSize,customerVo);

    }

    //添加
    @PostMapping("insert")
    public RR insert(@RequestBody TbCustomerIssues tbCustomerIssues) {
        return customerService.insert(tbCustomerIssues);
    }

    //修改
    @PutMapping("update")
    public RR update(@RequestBody TbCustomerIssues tbCustomerIssues){
        return customerService.update(tbCustomerIssues);
    }

    //回显查询
    @GetMapping("selectById/{id}")
    public RR selectById(@PathVariable Integer id){
        return customerService.selectById(id);
    }

    @DeleteMapping
    public RR deleteById(@RequestParam Integer id){
        return customerService.delete(id);
    }
}
